﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_AdminStudInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["StudIdcard"] != null)
            {
                bindDataTable();
            }
        }
    }
    private void bindDataTable()
    {
        DataTable dt = User_Control.getAllStudInfo();
        gv.DataSource = dt;
        gv.DataBind();
    }

    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv.PageIndex = e.NewPageIndex;
        bindDataTable();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string studId = studentId.Text.Trim();
        DataTable dt_view = User_Control.getStudentInfoByStudId(studId);
        if (dt_view.Rows.Count > 0)
        {
                gv.DataSource = dt_view;
                gv.DataBind();  
        }
        else
        {
            DataTable dt_card = User_Control.getStudInfoByIdCard(studId);
            if (dt_card.Rows.Count > 0)
            {
                gv.DataSource = dt_card;
                gv.DataBind();
            }
            else
            {
                gv.Visible = false;
            }
        }
    }
}